package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.ArrowImageView;
import com.huawei.appmarket.framework.widget.FoldingTextView;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailAppIntroBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailDescBean;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import java.util.LinkedHashMap;
import java.util.List;
import o.azb;
import o.cgz;
import o.cig;
import o.dge.d;
import o.dgh;
import o.dgm;
import o.dok;
import o.ContentManager;
import o.drg;
import o.eil;
import o.eqx;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class DetailDescGeneralCard extends BaseDistCard implements OnClickListener {
    protected ArrowImageView ʻ;
    protected ViewGroup ʼ;
    protected TextView ʽ;
    protected TextView ˊॱ;
    protected View ˋ;
    protected boolean ˋॱ = false;
    protected DetailDescBean ˏॱ;
    protected String ͺ;
    protected cig ॱˊ;
    protected FoldingTextView ॱॱ;
    protected TextView ᐝ;
    private LayoutInflater ᐝॱ;

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public DetailDescGeneralCard(Context context) {
        super(context);
    }

    public DetailDescGeneralCard ˎ(View view) {
        ॱ(view);
        this.ˋ = view;
        this.ᐝ = (TextView) this.ˋ.findViewById(j.ˏˌ);
        this.ʻ = (ArrowImageView) this.ˋ.findViewById(j.ˎꜟ);
        this.ॱॱ = (FoldingTextView) this.ˋ.findViewById(j.ˌᐝ);
        this.ॱॱ.setTextAlignment(5);
        ʽ(view);
        this.ᐝॱ = LayoutInflater.from(this.ʼॱ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        ˎ(cardBean);
    }

    protected boolean ˎ(CardBean cardBean) {
        DetailDescBean detailDescBean = (DetailDescBean) cardBean;
        if (detailDescBean == null) {
            return false;
        }
        this.ˏॱ = detailDescBean;
        String str = (String) this.ᐝ.getTag();
        if (!TextUtils.isEmpty(str) && str.equals(this.ˏॱ.ˊ())) {
            return false;
        }
        this.ᐝ.setTag(this.ˏॱ.ˊ());
        if (!ˋ()) {
            return false;
        }
        if (this.ॱॱ == null || TextUtils.isEmpty(detailDescBean.ॱ())) {
            return false;
        }
        ˊ();
        ʻ();
        return true;
    }

    public void onClick(View view) {
        ˎ();
        this.ˋॱ = !this.ˋॱ;
        if (this.ˋॱ) {
            this.ॱॱ.setText(this.ˏॱ.ॱ());
            this.ॱॱ.setVisibility(0);
            this.ʻ.setArrowUp(true);
            ᐝ();
            if (this.ʼ != null) {
                this.ʼ.setVisibility(0);
                return;
            }
            return;
        }
        this.ॱॱ.setText(this.ͺ);
        this.ʻ.setArrowUp(false);
        if (this.ʼ != null) {
            this.ʼ.setVisibility(8);
        }
    }

    public void ˏ(cig o_cig) {
        this.ॱˊ = o_cig;
    }

    protected void ˎ() {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("title", this.ˏॱ.ˊ());
        linkedHashMap.put("service_type", String.valueOf(dgm.ˎ((Activity) this.ॱॱ.getContext())));
        linkedHashMap.put("layoutid", this.ˏॱ.ॱˉ());
        dgh.ˋ("detail_updateintro_click", linkedHashMap);
        if (this.ˏॱ instanceof drg) {
            if (!TextUtils.isEmpty(((drg) this.ˏॱ).ꜟ())) {
                dgh.onEvent(new d(ContentManager.getInstant().getContext(), n.ॱʻ).ˏ(KeyAndValue.NUMBER_01).ˋ());
            }
        } else if (this.ˏॱ instanceof DetailAppIntroBean) {
            dgh.onEvent(new d(ContentManager.getInstant().getContext(), n.ˏˏ).ˏ(KeyAndValue.NUMBER_01).ˋ());
        }
    }

    protected boolean ˋ() {
        if (this.ᐝ == null || TextUtils.isEmpty(this.ˏॱ.ˊ())) {
            return false;
        }
        this.ᐝ.setText(this.ˏॱ.ˊ());
        if (!TextUtils.isEmpty(this.ˏॱ.ꜟ())) {
            ImageView imageView = (ImageView) this.ˋ.findViewById(j.ˎˌ);
            imageView.setVisibility(0);
            eqx.ˎ(imageView, this.ˏॱ.ꜟ());
        }
        return true;
    }

    protected void ˊ() {
        List ꜞ = this.ˏॱ.ꜞ();
        List ꓸ = this.ˏॱ.ꓸ();
        if (ꜞ != null && !ꜞ.isEmpty() && ꓸ != null && !ꓸ.isEmpty() && ꜞ.size() == ꓸ.size()) {
            this.ʼ = (ViewGroup) this.ˋ.findViewById(j.ˍˎ);
            for (int i = 0; i < ꜞ.size(); i++) {
                if (!TextUtils.isEmpty((CharSequence) ꜞ.get(i))) {
                    ViewGroup viewGroup = (ViewGroup) this.ᐝॱ.inflate(h.ˉ, null);
                    azb.ˏ(viewGroup, j.ـʼ);
                    this.ʽ = (TextView) viewGroup.findViewById(j.ʼﾞ);
                    this.ˊॱ = (TextView) viewGroup.findViewById(j.ˎˍ);
                    this.ʽ.setText((CharSequence) ꓸ.get(i));
                    this.ˊॱ.setText((CharSequence) ꜞ.get(i));
                    this.ʼ.addView(viewGroup);
                }
            }
        }
    }

    protected void ʻ() {
        if (this.ˏॱ.ᶥ()) {
            this.ͺ = this.ˏॱ.ॱ();
            if (this.ˏॱ.ॱ().length() > this.ˏॱ.ㆍ()) {
                int ㆍ = this.ˏॱ.ㆍ();
                if (dok.ˎ(this.ʼॱ)) {
                    ㆍ += ㆍ;
                }
                if (ㆍ < this.ˏॱ.ॱ().length()) {
                    this.ͺ = this.ˏॱ.ॱ().substring(0, ㆍ);
                    this.ͺ += "...";
                }
            }
            if (!(this.ͺ.equals(this.ˏॱ.ॱ()) && this.ʼ == null)) {
                ॱॱ();
                this.ʻ.setVisibility(0);
            }
            this.ॱॱ.setVisibility(0);
            this.ॱॱ.setText(this.ͺ);
            return;
        }
        this.ॱॱ.setText(this.ˏॱ.ॱ());
        this.ʻ.setVisibility(8);
    }

    protected void ॱॱ() {
        this.ॱॱ.setOnClickListener(this);
        this.ʻ.setOnClickListener(this);
        if (this.ʽ != null) {
            this.ʽ.setOnClickListener(this);
        }
        if (this.ˊॱ != null) {
            this.ˊॱ.setOnClickListener(this);
        }
    }

    protected void ᐝ() {
        eil.ˋ().ˎ(this.ˏॱ.ॱꓸ(), this.ˋ);
    }

    private void ॱ(View view) {
        azb.ˎ(view, j.ˏᐧ);
        azb.ˋ(view, j.ˏˍ);
        azb.ॱ(view, j.ˌˎ);
    }
}
